// JavaScript Document

window.onload = function(){
	var a = document.forms['myForm']['fName']
	//a.focus();
};

var field_length=0;
function tabNext(obj,event,len,next_field){
	if(event == "down"){
		field_length=obj.value.length;
		}
		else if(event == "up"){
			if(obj.value.length != field_length){
				field_length=obj.value.length;
					if(field_length == len){
						next_field.focus();
			};
		};
	};
};

function goForm(t){
	if(validate(t)){
		thanks();
	}
	else{
		return false;	
	};
};

function validate(){
	var name = /^([A-z]{2,})$/;
	var a = document.forms['myForm']['fName']
	if( name.test(a.value) != true ){
		alert('Please enter a valid first name.');
		a.focus();
		return false;
	};
	var b = document.forms['myForm']['lName']
	if( name.test(b.value) != true ){
		alert('Please enter a valid last name.');
		b.focus();
		return false;
	};
	var num1 = /^([0-9]{3})$/;
	var c = document.forms['myForm']['pNumber1']
	if( num1.test(c.value) != true){
		alert('Please enter a valid area code.')
		c.focus();
		return false;
	};
	var d = document.forms['myForm']['pNumber2']
	if( num1.test(d.value) != true){
		alert('Please enter three digits.')
		d.focus();
		return false;
	};
	var num2 = /^([0-9]{4})$/;
	var e = document.forms['myForm']['pNumber3']
	if( num2.test(e.value) != true){
		alert('Please enter four digits.')
		e.focus();
		return false;
	};
	var email = /^([\w]+)(.[\w]+)*@([\w]+)(.[\w]{2,3}){1,2}$/;
	var f = document.forms['myForm']['email']
	if( email.test(f.value) != true){
		alert('Please enter a valid email address.')
		f.focus();
		return false;
	};
	return true;
};


